import { push } from 'connected-react-router';
import * as types from '../actionTypes';
import { getUser } from '@/api/account';

export default {
    getUser (){
        return (dispatch) => {
            getUser().then(res => {
                if(res.message === 'success'){
                    const { data } = res;
                    dispatch({
                        type: types.USER,
                        user: {
                            userName: data.userName,
                            userCode: data.userCode
                        }
                    })
                }
            })
        }
    },
    goHome (){
        return push('/')
    }
}
